
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Django入门与实践-第8章：第一个单元测试 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="Fundamentals-3-2.html" />
    
    
    <link rel="prev" href="Fundamentals-3-1.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="GettingStarted.html">
            
                <a href="GettingStarted.html">
            
                    
                    Django入门与实践-第1章：环境搭建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="GettingStarted-2.html">
            
                <a href="GettingStarted-2.html">
            
                    
                    Django入门与实践-第2章：创建项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="gettingstarted-3.html">
            
                <a href="gettingstarted-3.html">
            
                    
                    Django入门与实践-第3章：Hello World
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="Fundamentals-1.html">
            
                <a href="Fundamentals-1.html">
            
                    
                    Django入门与实践-第4章：系统设计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="Fundamentals-2.html">
            
                <a href="Fundamentals-2.html">
            
                    
                    Django入门与实践-第5章：模型设计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="Fundamentals-3-0.html">
            
                <a href="Fundamentals-3-0.html">
            
                    
                    Django入门与实践-第6章：第一个视图函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="Fundamentals-3-1.html">
            
                <a href="Fundamentals-3-1.html">
            
                    
                    Django入门与实践-第7章：模板引擎设置
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.9" data-path="Fundamentals-3-1-1.html">
            
                <a href="Fundamentals-3-1-1.html">
            
                    
                    Django入门与实践-第8章：第一个单元测试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="Fundamentals-3-2.html">
            
                <a href="Fundamentals-3-2.html">
            
                    
                    Django入门与实践-第9章：静态文件设置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="Fundamentals-4.html">
            
                <a href="Fundamentals-4.html">
            
                    
                    Django入门与实践-第10章：Django Admin 介绍
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="AdvancedConcepts.html">
            
                <a href="AdvancedConcepts.html">
            
                    
                    Django入门与实践-第11章：URL 分发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="AdvancedConcept2.html">
            
                <a href="AdvancedConcept2.html">
            
                    
                    Django入门与实践-第12章：复用模板
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="AdvancedConcept3.html">
            
                <a href="AdvancedConcept3.html">
            
                    
                    Django入门与实践-第13章：表单处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="Authentication0.html">
            
                <a href="Authentication0.html">
            
                    
                    Django入门与实践-第14章：用户注册
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="Authentication1.html">
            
                <a href="Authentication1.html">
            
                    
                    Django入门与实践-第15章：用户注销
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="Authentication2.html">
            
                <a href="Authentication2.html">
            
                    
                    Django入门与实践-第16章：用户登录
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="DjangoORM0.html">
            
                <a href="DjangoORM0.html">
            
                    
                    Django入门与实践-第17章：保护视图
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="DjangoORM1.html">
            
                <a href="DjangoORM1.html">
            
                    
                    Django入门与实践-第18章：实现主题回复列表
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.20" data-path="DjangoORM2.html">
            
                <a href="DjangoORM2.html">
            
                    
                    Django入门与实践-第19章：实现主题回复功能
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.21" data-path="DjangoORM3.html">
            
                <a href="DjangoORM3.html">
            
                    
                    Django入门与实践-第20章：查询结果集
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.22" data-path="DjangoORM.html">
            
                <a href="DjangoORM.html">
            
                    
                    Django入门与实践-第21章：Django数据迁移
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.23" data-path="ClassBasedViews0.html">
            
                <a href="ClassBasedViews0.html">
            
                    
                    Django入门与实践-第22章：基于类的视图
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.24" data-path="ClassBasedViews1.html">
            
                <a href="ClassBasedViews1.html">
            
                    
                    Django入门与实践-第23章：分页实现
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.25" data-path="ClassBasedViews2.html">
            
                <a href="ClassBasedViews2.html">
            
                    
                    Django入门与实践-第24章：我的账户
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.26" data-path="ClassBasedViews3.html">
            
                <a href="ClassBasedViews3.html">
            
                    
                    Django入门与实践-第25章：Markdown支持
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.27" data-path="ClassBasedViews4.html">
            
                <a href="ClassBasedViews4.html">
            
                    
                    Django入门与实践-第26章：个性化设置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.28" data-path="Deployment.html">
            
                <a href="Deployment.html">
            
                    
                    Django入门与实践-第27章：项目部署
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >Django入门与实践-第8章：第一个单元测试</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="django&#x5165;&#x95E8;&#x6307;&#x5357;-&#x7B2C;8&#x7AE0;&#xFF1A;&#x7B2C;&#x4E00;&#x4E2A;&#x6D4B;&#x8BD5;&#x7528;&#x4F8B;">Django&#x5165;&#x95E8;&#x6307;&#x5357;-&#x7B2C;8&#x7AE0;&#xFF1A;&#x7B2C;&#x4E00;&#x4E2A;&#x6D4B;&#x8BD5;&#x7528;&#x4F8B;</h1>
<h3 id="&#x6D4B;&#x8BD5;&#x4E3B;&#x9875;">&#x6D4B;&#x8BD5;&#x4E3B;&#x9875;</h3>
<p><img src="statics/2-5.jpg" alt="2-5"></p>
<p>&#x6D4B;&#x8BD5;&#x5C06;&#x662F;&#x4E00;&#x4E2A;&#x53CD;&#x590D;&#x51FA;&#x73B0;&#x7684;&#x4E3B;&#x9898;&#xFF0C;&#x6211;&#x4EEC;&#x5C06;&#x5728;&#x6574;&#x4E2A;&#x6559;&#x7A0B;&#x7CFB;&#x5217;&#x4E2D;&#x4E00;&#x8D77;&#x63A2;&#x8BA8;&#x4E0D;&#x540C;&#x7684;&#x6982;&#x5FF5;&#x548C;&#x7B56;&#x7565;&#x3002;</p>
<p>&#x6211;&#x4EEC;&#x6765;&#x5F00;&#x59CB;&#x5199;&#x7B2C;&#x4E00;&#x4E2A;&#x6D4B;&#x8BD5;&#x3002;&#x73B0;&#x5728;&#xFF0C;&#x6211;&#x4EEC;&#x5C06;&#x5728;<strong>boards</strong>&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x5185;&#x7684;<strong>tests.py</strong>&#x6587;&#x4EF6;&#x4E2D;&#x64CD;&#x4F5C;</p>
<p><strong>boards/tests.py</strong></p>
<pre><code class="lang-ptyhon">from django.core.urlresolvers import reverse
from django.test import TestCase

class HomeTests(TestCase):
    def test_home_view_status_code(self):
        url = reverse(&apos;home&apos;)
        response = self.client.get(url)
        self.assertEquals(response.status_code, 200)
</code></pre>
<p>&#x8FD9;&#x662F;&#x4E00;&#x4E2A;&#x975E;&#x5E38;&#x7B80;&#x5355;&#x4F46;&#x975E;&#x5E38;&#x6709;&#x7528;&#x7684;&#x6D4B;&#x8BD5;&#x7528;&#x4F8B;&#xFF0C;&#x6211;&#x4EEC;&#x6D4B;&#x8BD5;&#x7684;&#x662F;&#x8BF7;&#x6C42;&#x8BE5;URL&#x540E;&#x8FD4;&#x56DE;&#x7684;&#x54CD;&#x5E94;&#x72B6;&#x6001;&#x7801;&#x3002;&#x72B6;&#x6001;&#x7801;200&#x610F;&#x5473;&#x7740;&#x6210;&#x529F;&#x3002;</p>
<p>&#x8BF7;&#x6C42;&#x4E00;&#x4E0B;&#x4E3B;&#x9875;&#x540E;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x5728;&#x63A7;&#x5236;&#x53F0;&#x4E2D;&#x770B;&#x5230;&#x54CD;&#x5E94;&#x7684;&#x72B6;&#x6001;&#x4EE3;&#x7801;&#xFF1A;</p>
<p><img src="statics/2-2-7.png" alt="2-2-7.png"></p>
<p>&#x5982;&#x679C;&#x51FA;&#x73B0;&#x672A;&#x6355;&#x83B7;&#x7684;&#x5F02;&#x5E38;&#xFF0C;&#x8BED;&#x6CD5;&#x9519;&#x8BEF;&#x6216;&#x5176;&#x4ED6;&#x4EFB;&#x4F55;&#x60C5;&#x51B5;&#xFF0C;Django&#x4F1A;&#x8FD4;&#x56DE;&#x72B6;&#x6001;&#x4EE3;&#x7801;500&#xFF0C;&#x8FD9;&#x610F;&#x5473;&#x7740;&#x662F;<strong>&#x5185;&#x90E8;&#x670D;&#x52A1;&#x5668;&#x9519;&#x8BEF;</strong>&#x3002;&#x73B0;&#x5728;&#xFF0C;&#x60F3;&#x8C61;&#x6211;&#x4EEC;&#x7684;&#x5E94;&#x7528;&#x7A0B;&#x5E8F;&#x6709;100&#x4E2A;&#x89C6;&#x56FE;&#x51FD;&#x6570;&#x3002;&#x5982;&#x679C;&#x6211;&#x4EEC;&#x4E3A;&#x6240;&#x6709;&#x89C6;&#x56FE;&#x7F16;&#x5199;&#x8FD9;&#x4E2A;&#x7B80;&#x5355;&#x7684;&#x6D4B;&#x8BD5;&#xFF0C;&#x53EA;&#x9700;&#x4E00;&#x4E2A;&#x547D;&#x4EE4;&#xFF0C;&#x6211;&#x4EEC;&#x5C31;&#x80FD;&#x591F;&#x6D4B;&#x8BD5;&#x6240;&#x6709;&#x89C6;&#x56FE;&#x662F;&#x5426;&#x8FD4;&#x56DE;&#x6210;&#x529F;&#x4EE3;&#x7801;&#xFF0C;&#x56E0;&#x6B64;&#x7528;&#x6237;&#x5728;&#x4EFB;&#x4F55;&#x5730;&#x65B9;&#x90FD;&#x770B;&#x4E0D;&#x5230;&#x4EFB;&#x4F55;&#x9519;&#x8BEF;&#x6D88;&#x606F;&#x3002;&#x5982;&#x679C;&#x6CA1;&#x6709;&#x81EA;&#x52A8;&#x5316;&#x6D4B;&#x8BD5;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x9010;&#x4E00;&#x68C0;&#x67E5;&#x6BCF;&#x4E2A;&#x9875;&#x9762;&#x662F;&#x5426;&#x6709;&#x9519;&#x8BEF;&#x3002;</p>
<p>&#x6267;&#x884C;Django&#x7684;&#x6D4B;&#x8BD5;&#x5957;&#x4EF6;&#xFF1A;</p>
<pre><code class="lang-sh">python manage.py <span class="hljs-built_in">test</span>
</code></pre>
<pre><code class="lang-sh">Creating <span class="hljs-built_in">test</span> database <span class="hljs-keyword">for</span> <span class="hljs-built_in">alias</span> <span class="hljs-string">&apos;default&apos;</span>...
System check identified no issues (0 silenced).
.
----------------------------------------------------------------------
Ran 1 <span class="hljs-built_in">test</span> <span class="hljs-keyword">in</span> 0.041s

OK
Destroying <span class="hljs-built_in">test</span> database <span class="hljs-keyword">for</span> <span class="hljs-built_in">alias</span> <span class="hljs-string">&apos;default&apos;</span>...
</code></pre>
<p>&#x73B0;&#x5728;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x6D4B;&#x8BD5;Django&#x662F;&#x5426;&#x5728;&#x8BF7;&#x6C42;&#x7684;URL&#x7684;&#x65F6;&#x5019;&#x8FD4;&#x56DE;&#x4E86;&#x6B63;&#x786E;&#x7684;&#x89C6;&#x56FE;&#x51FD;&#x6570;&#x3002;&#x8FD9;&#x4E5F;&#x662F;&#x4E00;&#x4E2A;&#x6709;&#x7528;&#x7684;&#x6D4B;&#x8BD5;&#xFF0C;&#x56E0;&#x4E3A;&#x968F;&#x7740;&#x5F00;&#x53D1;&#x7684;&#x8FDB;&#x5C55;&#xFF0C;&#x60A8;&#x4F1A;&#x53D1;&#x73B0;urls.py&#x6A21;&#x5757;&#x53EF;&#x80FD;&#x53D8;&#x5F97;&#x975E;&#x5E38;&#x5E9E;&#x5927;&#x800C;&#x590D;&#x6742;&#x3002;URL conf &#x5168;&#x90E8;&#x662F;&#x5173;&#x4E8E;&#x89E3;&#x6790;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x3002;&#x6709;&#x4E9B;&#x60C5;&#x51B5;&#x4E0B;&#x6709;&#x4E00;&#x4E2A;&#x975E;&#x5E38;&#x5BBD;&#x5BB9;&#x7684;URL&#xFF08;&#x8BD1;&#x6CE8;&#xFF1A;&#x672C;&#x6765;&#x4E0D;&#x5E94;&#x8BE5;&#x5339;&#x914D;&#x7684;&#xFF0C;&#x5374;&#x56E0;&#x4E3A;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x5199;&#x7684;&#x8FC7;&#x4E8E;&#x5BBD;&#x6CDB;&#x800C;&#x9519;&#x8BEF;&#x7684;&#x5339;&#x914D;&#x4E86;&#xFF09;&#xFF0C;&#x6240;&#x4EE5;Django&#x6700;&#x7EC8;&#x53EF;&#x80FD;&#x8FD4;&#x56DE;&#x9519;&#x8BEF;&#x7684;&#x89C6;&#x56FE;&#x51FD;&#x6570;&#x3002;</p>
<p>&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x8FD9;&#x6837;&#x505A;&#xFF1A;</p>
<p><strong>boards/tests.py</strong></p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> django.core.urlresolvers <span class="hljs-keyword">import</span> reverse
<span class="hljs-keyword">from</span> django.urls <span class="hljs-keyword">import</span> resolve
<span class="hljs-keyword">from</span> django.test <span class="hljs-keyword">import</span> TestCase
<span class="hljs-keyword">from</span> .views <span class="hljs-keyword">import</span> home

<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">HomeTests</span><span class="hljs-params">(TestCase)</span>:</span>
    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">test_home_view_status_code</span><span class="hljs-params">(self)</span>:</span>
        url = reverse(<span class="hljs-string">&apos;home&apos;</span>)
        response = self.client.get(url)
        self.assertEquals(response.status_code, <span class="hljs-number">200</span>)

    <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">test_home_url_resolves_home_view</span><span class="hljs-params">(self)</span>:</span>
        view = resolve(<span class="hljs-string">&apos;/&apos;</span>)
        self.assertEquals(view.func, home)
</code></pre>
<p>&#x5728;&#x7B2C;&#x4E8C;&#x4E2A;&#x6D4B;&#x8BD5;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x4F7F;&#x7528;&#x4E86;<code>resolve</code>&#x51FD;&#x6570;&#x3002;Django&#x4F7F;&#x7528;&#x5B83;&#x6765;&#x5C06;&#x6D4F;&#x89C8;&#x5668;&#x53D1;&#x8D77;&#x8BF7;&#x6C42;&#x7684;URL&#x4E0E;urls.py&#x6A21;&#x5757;&#x4E2D;&#x5217;&#x51FA;&#x7684;URL&#x8FDB;&#x884C;&#x5339;&#x914D;&#x3002;&#x8BE5;&#x6D4B;&#x8BD5;&#x7528;&#x4E8E;&#x786E;&#x5B9A;URL <code>/</code> &#x8FD4;&#x56DE; home &#x89C6;&#x56FE;&#x3002;</p>
<p>&#x518D;&#x6B21;&#x6D4B;&#x8BD5;&#xFF1A;</p>
<pre><code class="lang-sh">python manage.py <span class="hljs-built_in">test</span>
</code></pre>
<pre><code class="lang-sh">```sh
Creating <span class="hljs-built_in">test</span> database <span class="hljs-keyword">for</span> <span class="hljs-built_in">alias</span> <span class="hljs-string">&apos;default&apos;</span>...
System check identified no issues (0 silenced).
..
----------------------------------------------------------------------
Ran 2 tests <span class="hljs-keyword">in</span> 0.027s

OK
Destroying <span class="hljs-built_in">test</span> database <span class="hljs-keyword">for</span> <span class="hljs-built_in">alias</span> <span class="hljs-string">&apos;default&apos;</span>...
</code></pre>
<p>&#x8981;&#x67E5;&#x770B;&#x6709;&#x5173;&#x6D4B;&#x8BD5;&#x6267;&#x884C;&#x65F6;&#x66F4;&#x8BE6;&#x7EC6;&#x7684;&#x4FE1;&#x606F;&#xFF0C;&#x53EF;&#x5C06;<strong>verbosity</strong>&#x7684;&#x7EA7;&#x522B;&#x8BBE;&#x7F6E;&#x5F97;&#x66F4;&#x9AD8;&#x4E00;&#x70B9;&#xFF1A;</p>
<pre><code class="lang-sh">python manage.py <span class="hljs-built_in">test</span> --verbosity=2
</code></pre>
<pre><code class="lang-sh">Creating <span class="hljs-built_in">test</span> database <span class="hljs-keyword">for</span> <span class="hljs-built_in">alias</span> <span class="hljs-string">&apos;default&apos;</span> (<span class="hljs-string">&apos;file:memorydb_default?mode=memory&amp;cache=shared&apos;</span>)...
Operations to perform:
  Synchronize unmigrated apps: messages, staticfiles
  Apply all migrations: admin, auth, boards, contenttypes, sessions
Synchronizing apps without migrations:
  Creating tables...
    Running deferred SQL...
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying contenttypes.0002_remove_content_<span class="hljs-built_in">type</span>_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying boards.0001_initial... OK
  Applying sessions.0001_initial... OK
System check identified no issues (0 silenced).
<span class="hljs-built_in">test</span>_home_url_resolves_home_view (boards.tests.HomeTests) ... ok
<span class="hljs-built_in">test</span>_home_view_status_code (boards.tests.HomeTests) ... ok

----------------------------------------------------------------------
Ran 2 tests <span class="hljs-keyword">in</span> 0.017s

OK
Destroying <span class="hljs-built_in">test</span> database <span class="hljs-keyword">for</span> <span class="hljs-built_in">alias</span> <span class="hljs-string">&apos;default&apos;</span> (<span class="hljs-string">&apos;file:memorydb_default?mode=memory&amp;cache=shared&apos;</span>)...
</code></pre>
<p>Verbosity&#x51B3;&#x5B9A;&#x4E86;&#x5C06;&#x8981;&#x6253;&#x5370;&#x5230;&#x63A7;&#x5236;&#x53F0;&#x7684;&#x901A;&#x77E5;&#x548C;&#x8C03;&#x8BD5;&#x4FE1;&#x606F;&#x91CF;; 0&#x662F;&#x65E0;&#x8F93;&#x51FA;&#xFF0C;1&#x662F;&#x6B63;&#x5E38;&#x8F93;&#x51FA;&#xFF0C;2&#x662F;&#x8BE6;&#x7EC6;&#x8F93;&#x51FA;&#x3002;</p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="Fundamentals-3-1.html" class="navigation navigation-prev " aria-label="Previous page: Django入门与实践-第7章：模板引擎设置">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="Fundamentals-3-2.html" class="navigation navigation-next " aria-label="Next page: Django入门与实践-第9章：静态文件设置">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Django入门与实践-第8章：第一个单元测试","level":"1.9","depth":1,"next":{"title":"Django入门与实践-第9章：静态文件设置","level":"1.10","depth":1,"path":"Fundamentals-3-2.md","ref":"./Fundamentals-3-2.md","articles":[]},"previous":{"title":"Django入门与实践-第7章：模板引擎设置","level":"1.8","depth":1,"path":"Fundamentals-3-1.md","ref":"./Fundamentals-3-1.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["include-codeblock","livereload"],"pluginsConfig":{"include-codeblock":{"check":false,"edit":false,"fixlang":false,"lang":"","template":"default","theme":"chrome","unindent":false},"livereload":{},"highlight":{},"search":{},"lunr":{"ignoreSpecialCharacters":false,"maxIndexSize":1000000},"sharing":{"all":["facebook","google","instapaper","twitter","weibo"],"facebook":true,"google":false,"instapaper":false,"twitter":true,"vk":false,"weibo":false},"fontsettings":{"family":"sans","size":2,"theme":"white"},"theme-default":{"showLevel":false,"styles":{"ebook":"styles/ebook.css","epub":"styles/epub.css","mobi":"styles/mobi.css","pdf":"styles/pdf.css","print":"styles/print.css","website":"styles/website.css"}}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"ebook":"styles/ebook.css","epub":"styles/epub.css","mobi":"styles/mobi.css","pdf":"styles/pdf.css","print":"styles/print.css","website":"styles/website.css"}},"file":{"path":"Fundamentals-3-1-1.md","mtime":"2018-05-13T13:48:46.866Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-05-13T12:52:49.928Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

